//
//  ECBaseViewController.m
//  ERPChargeAccount2
//
//  Created by 刘思麟 on 2018/6/7.
//  Copyright © 2018年 历山大亚. All rights reserved.
//

#import "ECBaseViewController.h"

@interface ECBaseViewController ()

@property (nonatomic,strong) UIView * noDataView;

@end

@implementation ECBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    if (iOS7Later) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:ECCOLOR_NAVIBACK] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor clearColor]]];
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"return_icon"] style:UIBarButtonItemStylePlain target:self action:@selector(doPop)];
    self.navigationController.navigationBar.backIndicatorImage = [UIImage imageWithColor:[UIColor clearColor] size:CGSizeMake(0.0001, 0.1)];
    self.navigationController.navigationBar.backIndicatorTransitionMaskImage = [UIImage imageWithColor:[UIColor clearColor] size:CGSizeMake(0.0001, 0.1)];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:ECFONT(18*PX_RELATIVE375)}];
    [self.view addSubview:self.noDataView];
    [self.noDataView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.bottom.mas_equalTo(0);
    }];
    [self loadSubView];
    [self.view bringSubviewToFront:self.noDataView];
    //测试时候打开
    self.dataState = ECBaseDataStateData;
    // Do any additional setup after loading the view.
}

- (void)doPop {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)loadSubView {
    
}

- (void)setDataState:(ECBaseDataState)dataState {
    _dataState = dataState;
    switch (_dataState) {
        case ECBaseDataStateLoading:{
            
        }
            break;
        case ECBaseDataStateNOData:{
            
        }
            break;
        case ECBaseDataStateData:{
            self.noDataView.hidden = YES;
        }
            break;
        default:
            break;
    }
}

- (UIView *)noDataView {
    if (!_noDataView) {
        _noDataView = [UIView new];
        _noDataView.backgroundColor = [UIColor whiteColor];
    }
    return _noDataView;
}

@end
